﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
   <meta charset="utf-8" />
  	  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Dreamer Blog - 后台管理系统</title> 
    <!-- bootstrap 3.0.2 -->
    <link href="/resource/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="/resource/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="all" href="/resource/js/plugins/treeSelect/css/zTreeStyle.css"/>
	<link rel="stylesheet" type="text/css" media="all" href="/resource/js/plugins/treeSelect/css/treeSelect.css"/>
    <link rel="stylesheet" type="text/css" href="/resource/js/jQueryMessage/css/message.skin.css" />
</head>

<body>
	<div class="row">
	    <div class="col-md-12">
	    	<h1 class="panel-heading">编辑权限</h1>
	        <!--breadcrumbs start -->
	        <ul class="breadcrumb">
				<li><a href="/admin/dashboard/toIndex"><i class="fa fa-home"></i> 首页</a></li>
				<li class="active">编辑权限</li>
			</ul>
	        <!--breadcrumbs end -->
	    </div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<section class="panel">
				<div class="panel-body">
					<form class="col s12" id="form1" th:action="@{/admin/permission/update}" onsubmit="return validateForm();" method="post">
						<input type="hidden" th:value="${permission.id}" id="id" name="id"/>
						<div class="form-group form-control-medium">
							<label for="permissionName">权限名称：</label>
							<input id="permissionName" name="permissionName" type="text" th:value="${permission.permissionName}" class="form-control" />
						</div>
						<div class="form-group form-control-medium">
							<label for="permissionCode">权限编码：</label>
							<input id="permissionCode" name="permissionCode" type="text" th:value="${permission.permissionCode}" readonly="readonly" class="form-control"/>
						</div>
						<div class="form-group form-control-medium">
							<label for="permissionUrl">权限路径：</label>
							<input id="permissionUrl" name="permissionUrl" th:value="${permission.permissionUrl}" type="text" class="form-control"/>
						</div>
						<div class="form-group form-control-medium">
							<label for="parentId">所属菜单：</label>
							<div style="width: 100%;" class="treeSelect form-group form-control-medium"></div>
						</div>
						<div class="form-group form-control-medium">
							<label for="remark">备注：</label>
							<textarea rows="5" name="remark" class="form-control" th:text="${permission.remark}"></textarea>
						</div>
						<div class="form-btn-group-left">
			            	<button type="submit" class="btn btn-info">保存</button>
			            </div>
					</form>
				</div>
			</section>
		</div>
	</div>
	<script src="/resource/js/jquery.min.js" type="text/javascript"></script>
	<script src="/resource/js/plugins/treeSelect/jquery.ztree.all.min.js"></script>
	<script src="/resource/js/plugins/treeSelect/treeSelect.js"></script>
    <script type="text/javascript" src="/resource/js/jQueryMessage/js/jquery.plugin.message.js"></script>
    <script type="text/javascript" th:inline="javascript">
    	var currentPermission = [[${permission}]];
	    var allList = [[${menuList}]];
	
		$(function () {
			$(".treeSelect").treeSelect({
		    	data: allList,
		        inputId: "menuId",
		        name: "menuId",
	        	defaultKey: currentPermission.menuName,
    	        defaultValue: currentPermission.menuId
		    })
		});
	   	/* 保存方法 */
	    function validateForm(){
	    	var permissionName = $("#permissionName").val();
	    	var permissionUrl = $("#permissionUrl").val();
	    	if(permissionName == null || permissionName==''){
	    		$("body").MessageBox({
					type: 'error',
					message:'权限名称不能为空！',
					timeout:3000,
					callbak:null
				});
	    		return false;
	    	}
	    	if(permissionUrl == null || permissionUrl==''){
	    		$("body").MessageBox({
					type: 'error',
					message:'权限URL不能为空',
					timeout:3000,
					callbak:null
				});
	    		return false;
	    	}
	    	return true;
	    }
    </script>
</body>
</html>
